<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.edu.service.*"%>
<%@ page import="com.edu.service.impl.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.edu.entity.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="x" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/teacher.css">
</head>
<script type="text/javascript" src="js/jquery-3.7.1.js"></script>
<body>
	<form id="form" method="post">
			<div id="myid1">
 		<p><img src="image/2.png"><span>学生管理系统</span></p><br>
	   <ul>
	      <li><img src="image/3.png"><a href="class.jsp">班级管理</a></li><br><br><br>
		      <li><img src="image/4.png"><a href="teacher.jsp">老师管理</a></li><br><br><br>
		      <li><img src="image/5.png"><a href="student.jsp" >学生管理</a></li><br><br><br>
		      <li><img src="image/6.png"><a href="grade.jsp">成绩管理</a></li><br><br><br>
		      <li><img src="image/7.png"><a href="updatePass.jsp">修改密码</a></li><br><br><br>
		      <li><img src="image/8.png"><a href="log.jsp">退出登录</a></li><br><br><br>
	   </ul>
   
</div>
<div id="myWork">
      <div id="myTeacher1">
             <p>
			             班级: <select name="tClass">
			                 <option>1年级1班</option>
			                 <option>1年级2班</option>
			                 <option>1年级3班</option>
			                 <option>1年级4班</option>
			           </select>&nbsp;&nbsp;
                 	姓名/电话: <input type="text" name="tName">
                 	 <input type="button" value="搜索" id="SouSuo" onclick="showAction('SelectTeacherServlet')">
				     <input type="button" value="新增" id="myAdd" onclick="showAction('TAdd.jsp')">
            </p>
    </div>
    <table>
        <tr>
           <td>老师序号</td>
           <td>班级</td>
           <td>姓名</td>
           <td>性别</td>
           <td>手机号</td>
           <td>生日</td>
           <td>操作</td>
        </tr>
        <%
	        request.setCharacterEncoding("UTF-8");
	        Object obj=request.getAttribute("list");
	        if(obj==null){
	        	 UserService userservice=new UserServiceimpl();
	        	 List<Teacher> teacher=userservice.tSelect();
	             request.setAttribute("list", teacher);
	        }
        %>
	        <x:forEach items="${list }" var="teacher" varStatus="status">
		        <x:choose>
			        <x:when test="${status.count%2==0 }">
			           <tr style="background-color:#ccc;">
				           <td>${teacher.tId }</td>
				           <td>${teacher.tClass }</td>
				           <td>${teacher.tName }</td>
				           <td>${teacher.tSex }</td>
				           <td>${teacher.tPhone }</td>
				           <td>${teacher.tBir }</td>
				           <td>
				           		<a href="TUpdate.jsp?tId=${teacher.tId}&tClass=${teacher.tClass}&tName=${teacher.tName }&tSex=${teacher.tSex }&tPhone=${teacher.tPhone }&tBir=${teacher.tBir }" id="myBj">编辑</a>
		                 		<a href="TdelServlet?tId=${teacher.tId}" id="myDel">删除</a>
				           </td>
			        </tr>
			        </x:when>
			        <x:otherwise>
			            <tr>
			           <td>${teacher.tId }</td>
			           <td>${teacher.tClass }</td>
			           <td>${teacher.tName }</td>
			           <td>${teacher.tSex }</td>
			           <td>${teacher.tPhone }</td>
			           <td>${teacher.tBir }</td>
			           <td>
			           		<a href="TUpdate.jsp?tId=${teacher.tId}&tClass=${teacher.tClass}&tName =${teacher.tName }&tSex=${teacher.tSex }&tPhone=${teacher.tPhone }&tBir=${teacher.tBir }" id="myBj">编辑</a>
		                 	<a href="TdelServlet?tId=${teacher.tId}" id="myDel">删除</a>
			           </td>
			        </tr>
			        </x:otherwise>
		        </x:choose>
	          
        </x:forEach>
    </table>
    
</div>
	<input type="hidden" name="tClass">
	<input type="hidden" name="tName">   
	</form>
</body>
<script>
     function $(id){
    	 return document.getElementById(id);
     }
    function showAction(url){
    	$("form").action=url;
    	$("form").submit();
    }
</script>
</html>